package j04map;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/*
，map
映射
单列集合
    {"aa","bb,cc }
map 双列集合
k v t  e
键值对的
    键-key，属性名  -k
    值-value，属性值 v

tree
    age = 4
    age = 6 不许重复
 */
public class J1 {
    public static void main(String[] args) {
        HashMap<String,Integer> map = new HashMap<>();
        map.put("age",3);
        map.put("name",9527);
        map.put("blood",2000);

//        map.remove("age");
//        map.remove("age",2);//
//        map.put("age",100);
//        map.put("blood",100);
//        map.replace("power",8);
//
//        System.out.println("map = " + map);

        System.out.println(map.get("blood"));//2000
        System.out.println(map.get("blood1"));//null
        System.out.println(map.getOrDefault("blood1",0));//0

//        Map<String,Integer> map2 = new HashMap<>();
//        map2.putAll(map);
//        System.out.println("map2 = " + map2);
    }
}
interface I1{
    interface I2{}
}
class J2{
    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        map.put("name","luxun");
        map.put("nick","luxun");
        map.put("age","中年");
        map.put("sex","boy");
        Set<String> set = map.keySet();
        System.out.println("set = " + set);

        Collection<String> collection = map.values();
        System.out.println("collection = " + collection);
        System.out.println("=====");
        Set<Map.Entry<String,String>> s2 = map.entrySet();
        System.out.println("s2 = " + s2);

        System.out.println(map.containsKey("age"));//true
        System.out.println(map.containsValue("中年"));//true


    }
}